package com.red.star.wechat.data.utils;

import com.google.common.collect.Lists;
import com.red.star.wechat.data.entity.SysParam;
import com.red.star.wechat.data.entity.vo.StyleResponse;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName CommonUtil
 * @Description 公用类
 * @Author xuquanyu
 * @Date 2018/8/2113:36
 * @Version 1.0
 **/
public class CommonUtil {
    /**
     * 初始化图片模板样式信息
     *
     * @return
     */
    public static List<StyleResponse> initImageTemplateStyleResponse() {
        String[] styles = SysParam.IMAGE_STYLE_INFO.split(";");
        List<StyleResponse> styleResponseList = Lists.newArrayList();
        StyleResponse styleResponse;
        for (String string : styles) {
            styleResponse = new StyleResponse();
            String[] split = string.split("#");
            if (!CheckUtil.isEmpty(split) && split.length == 2) {
                styleResponse.setStyleCode(split[0]);
                styleResponse.setStyleName(split[1]);
                styleResponseList.add(styleResponse);
            }
        }
        return styleResponseList;
    }

    public static Map<String,String> initStyleImage(){
        List<String> strings = Arrays.asList(SysParam.IMAGE_STYLE_INFO.split(";"));
        Map<String,String> map = new HashMap();
        map.put("左",strings.get(0));
        map.put("右",strings.get(1));
        return map;
    }

    public static Map<String,String> initImageChoiceQRCode(){
        List<String> strings = Arrays.asList(SysParam.IMAGE_CHOICE_QRCODE.split(";"));
        Map<String,String> map = new HashMap();
        map.put("0",strings.get(0));
        map.put("1",strings.get(1));
        map.put("2",strings.get(2));
        map.put("3",strings.get(3));
        return map;
    }

    public static Map<String,String> initImageChoiceQRCode(Integer var){
        List<String> strings = Arrays.asList(SysParam.IMAGE_CHOICE_QRCODE.split(";"));
        Map<String,String> map = new HashMap();
        map.put("0",strings.get(0));
        map.put("1",strings.get(1));
        map.put("3",strings.get(3));
        return map;
    }

}
